<?
include_once("../functions/functions.php");
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="print.css">
<style>
body, td {
	font-size: 10pt;
}
.noborder {
	border: 0px solid #ffffff;
}
</style>
<script LANGUAGE="JavaScript">
<!--
function windowPrint() {
	window.print();
	setTimeout("window.close();",1500);
}
 -->
</script>
</head>
<body onload="windowPrint(); ">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="normal" width="60%"><b>EMERGENCY RELIEF APPLICATION - New Client</b></td>
    <td class="normal" width="13%">
      <div align="center">Ashburton</div>
    </td>
    <td class="normal" width="13%">
      <div align="center">Camberwell</div>
    </td>
    <td class="normal">
      <div align="center">Kew</div>
    </td>
  </tr>
  <tr>
    <td class="normal" width="60%">&nbsp;</td>
    <td colspan="3" class="normal">
      <div align="center" class="small">(please circle)</div>
    </td>
  </tr>
</table>

<table id="AutoNumber1" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="1">
  <tr>
    <td colSpan="2" class="normal"> Surname:&nbsp; </td>
    <td colSpan="2" class="normal"> Given Name:</td>
  </tr>
  <tr>
    <td  colSpan="4" class="normal" > Address: </td>
  </tr>
  <tr>
    <td colSpan="2" class="normal" > Suburb: </td>
    <td class="normal"> Postcode: </td>
    <td class="normal"> State:</td>
  </tr>
  <tr>
    <td colSpan="2" class="normal"> Phone Number: </td>
    <td colSpan="2" class="normal"> Mobile Number: </td>
  </tr>
  <tr>
    <td class="normal" width="25%"> DOB:</td>
    <td class="normal" width="25%"> Age:</td>
    <td colSpan="2" class="normal">Gender: <span class="small">(please circle)</span>
      <i> &nbsp; </i><b>Male</b><i> / </i><b>Female</b>
    </td>
  </tr>
  <tr>
    <td colSpan="2" class="normal"> ID Type:</td>
    <td colSpan="2" class="normal"> ID Reference:</td>
  </tr>
  <tr>
    <td colSpan="2" class="normal">Income Source:</td>
    <td colSpan="2" class="normal">Income Status:</td>
  </tr>
  <tr>
    <td colSpan="2" class="normal"> Total Amount:</td>
    <td colSpan="2" class="normal">When Due :</td>
  </tr>
  <tr valign="top">
    <td class="normal" colspan="2" valign="top">No. Persons Requesting Assistance</td>
    <td width="25%" class="normal" valign="top">No. of Adult: <span style="font-size: 8pt;">(including children 13 & over on card)</span></td>
    <td width="25%" class="normal" valign="top">No. of Children: <span style="font-size: 8pt;">(under 13)<br />(must be listed on benefit card)</span></td>
  </tr>
  <tr>
    <td width="25%" class="normal">Housing type:</td>
    <td width="25%" class="normal">Rent paid pf($):</td>
  </tr>
</table>
<span class="small"><br /></span>
<table id="AutoNumber2" cellSpacing="0" cellPadding="3" width="100%" border="1" bordercolor="#000000">
  <tr>
    <td align="right" width="25%" class="normal">
      <div align="center"><b>Current Year Visits </b></div>
    </td>
    <td class="normal">
      <div align="center"><b>1st Visit</b></div>
    </td>
  </tr>
  <?
  	$x = 6;
	$queryPayment = "SELECT * FROM er_payment WHERE payment_id < $x";
	$resultPayment = r_db($queryPayment);

	while ($rowPayment = mysql_fetch_array($resultPayment))

		{
			if ($rowPayment[1] == "Other") {
				$rowPayment[1] = "Other  <span class=\"small\">(please specify)</span><br>..........................";
			}
			echo "<tr>";
			echo "<td class=\"normal\" align=\"right\">$rowPayment[1] ($)</td>\n";
			echo "<td class=\"normal\">&nbsp;</td>\n";
			echo "</tr>";
		}

?>
  <tr>
    <td width="25%" align="right" class="normal"> Total Amount $</td>
    <td class="normal">&nbsp;</td>
  </tr>
    <tr>

	<td width="25%" align="right" class="normal">Extra Food Parcels: </td>
	<td class="normal">&nbsp;</td>
  </tr>
</table>
<span class="small"><br /></span>
<table id="AutoNumber3" borderColor="#111111" cellSpacing="0" cellPadding="3" width="100%" border="1">
  <tr>
    <td width="50%" class="normal"> Cheque Number:</td>
    <td width="50%" class="normal">Payee:</td>
  </tr>
  <tr>
    <td width="100%" colSpan="2"  class="normal"> Client Referred
      by:</td>
  </tr>
</table>

  <?
/* get the checkbox labels */


$emergencyReliefs = get_labels_er("er_Emergency_Relief");

/* create the html code for a formatted set of
checkboxes */
$html_incomes = make_er_checkbox_html($emergencyReliefs, 4, "emergencyReliefs[]");

?>

<tr>
<p align="left"><u><b>REASON FOR SEEKING ASSISTANCE</b></p></u>
   <?
      //==================================EMERGENCY RELIEFS===========================
      echo "\n";
      echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n";
      echo "$html_incomes";
      echo "</table>\n";
      function make_er_checkbox_html($arr, $num, $name)
      {
      	$closingTR = false;
      	$str = "";
      	$str .= "<tr>\n";
      	if (count($arr) % $num != 0)
      	{
      		$closingTR = true;
      	}

      	$i=1;

      	foreach ($arr as $ele)
      	{
      		$str .= "<td><input type=\"checkbox\" name=\"$name\" value=\"$ele->er_id\">";
      		$str .= "$ele->er_reason\n</td>";
      		if($ele->er_reason=="Other")
      		{
      			$str .= "<td>Other Reason:</td>";
      			$str .= "<td><input type=\"text\" name=\"txtOtherEr\" size=\"20\" maxlength=\"50\"></td>";
      		}
      		//$str .= "</tr>";
      		if ($i % $num == 0)
      		{
      			$str .= "</tr>\n<tr>";
      		}
      		else
      		{
      			$str .= "</td>\n";
      		}
      		$i++;
      	}


      	return $str;
      }
?>
<br />

<p align="left"><u><b>ACTION TAKEN ASSOCIATED WITH E.R. (E.G. REFERRED TO OTHER SERVICES AND AGENCIES)</b></p></u>



  <?	//==================================ACTION TAKEN===========================
/* get the checkbox labels */


$actionTaken = get_labels_actionTaken("er_action_taken");

/* create the html code for a formatted set of
checkboxes */

$html_action = make_action_checkbox_html($actionTaken, 3, "actionTaken[]");

?>

   <?

      echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">\n";

      echo "$html_action";
      echo "</table>\n";
      function make_action_checkbox_html($arr, $num, $name)
      {
      	$closingTR = false;
      	$str = "";
      	$str .= "<tr>\n";
      	if (count($arr) % $num != 0)
      	{
      		$closingTR = true;
      	}

      	$i=1;

      	foreach ($arr as $ele)
      	{
      		$str .= "<td><input type=\"checkbox\" name=\"$name\" value=\"$ele->action_id\">";
      		$str .= "$ele->action_taken\n</td>";
      		if($ele->action_taken=="Other")
      		{
      			$str .= "<td>Other Reason(financial only):</td>";
      			$str .= "<td><input type=\"text\" name=\"txtActionOther\" size=\"20\" maxlength=\"50\"></td>";
      		}
      		if($ele->action_taken=="Discussed Return Date(if no entitlement or not eligible)")
      		{
      			$str .= "<td>Return date:</td>";
      			$str .= "<td><input type=\"text\" name=\"txtReturnDate\" size=\"20\" maxlength=\"50\"></td>";
      		}
      		//$str .= "</tr>";
      		if ($i % $num == 0)
      		{
      			$str .= "</tr>\n<tr>";
      		}
      		else
      		{
      			$str .= "</td>\n";
      		}
      		$i++;
      	}


      	return $str;
      }
?>



<table id="AutoNumber3" borderColor="#111111" cellSpacing="0" cellPadding="6" width="100%" border="0">
  <tr valign="top">
    <td width="33%" class="normal">
      <div align="center">Interviewer's Name</div>
    </td>
    <td width="33%" class="normal">
      <div align="center">Client's Signature</div>
    </td>
    <td class="normal">
      <div align="center">Date of Visit</div>
    </td>
  </tr>
  <tr>
    <td width="33%" class="normal">
      <div align="center">.....................................</div>
    </td>
    <td width="33%" class="normal">
      <div align="center">.....................................</div>
    </td>
    <td class="normal">
      <div align="center">.....................................</div>
    </td>
  </tr>
</table>

<div align="left">Privacy: Camcare respects your privacy. Please ask a staff member to show you the Privacy Policy</div>
</body>
</html>
<?
function getNoOfVisits($clientID)

{

	$queryNoOfVisits = "SELECT er_Client.client_id, COUNT(er_visit.visit_id)

						FROM er_Client, er_visit

						WHERE er_Client.client_id=er_visit.client_id

						AND YEAR(visit_date) >= YEAR(DATE_SUB(NOW(), INTERVAL 1 YEAR))

						AND er_Client.client_id='$clientID'

						GROUP BY er_Client.client_id";

	$resultNoOfVisits = r_db($queryNoOfVisits);



	$rowNoOfVisits = mysql_fetch_array($resultNoOfVisits);



	$noOfVisits = $rowNoOfVisits[1];

	return $noOfVisits;

}
?>